import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../views/Login.vue'
import Home from '../views/Home.vue'
import Register from '../views/Register.vue'
// import Dash from '../views/Admin/Dash.vue'
// import Orderlist from '../views/Admin/Orderlist.vue'

Vue.use(VueRouter)

const routes = [{
		path: '/',
		name: 'Register',
		component: Register
	}, {
		path: '/login',
		name: 'Login',
		component: Login
	},
	{
		path: '/home',
		name: 'Home',
		component: Home,
		meta:{auth:true},
		// 配置子路由
		children: [{
				path: 'transaction',
				// 用到才开始加载，路由懒加载
				component: () => import( /* webpackChunkName:"Transaction" */
					'../views/ChildrensPage/Transaction/Transaction.vue'),
				children: [{
						path: 'receipt',
						component: () => import( /*webpackChunkName:"Receipt"*/
							'../views/ChildrensPage/Transaction/Receipt.vue')
					},
					{
						path: 'batchCollection',
						component: () => import( /*webpackChunkName:"batchCollection"*/
							'../views/ChildrensPage/Transaction/BatchCollection.vue')
					},
					{
						path: 'batchRefund',
						component: () => import( /*webpackChunkName:"batchRefund"*/
							'../views/ChildrensPage/Transaction/BatchRefund.vue')
					},
					{
						path: 'dateSend',
						component: () => import( /*webpackChunkName:"dateSend"*/
							'../views/ChildrensPage/Transaction/DateSend.vue')
					},
					{
						path: 'dayDown',
						component: () => import( /*webpackChunkName:"dayDown"*/
							'../views/ChildrensPage/Transaction/DayDown.vue')
					},
					{
						path: 'discount',
						component: () => import( /*webpackChunkName:"discount"*/
							'../views/ChildrensPage/Transaction/Discount.vue')
					},
					{
						path: 'earlySettlement',
						component: () => import( /*webpackChunkName:"earlySettlement"*/
							'../views/ChildrensPage/Transaction/EarlySettlement.vue')
					},
					{
						path: 'profit',
						component: () => import( /*webpackChunkName:"profit"*/
							'../views/ChildrensPage/Transaction/Profit.vue')
					},
					{
						path: 'realtime',
						component: () => import( /*webpackChunkName:"realtime"*/
							'../views/ChildrensPage/Transaction/Realtime.vue')
					},
					{
						path: 'receiptBill',
						component: () => import( /*webpackChunkName:"receiptBill"*/
							'../views/ChildrensPage/Transaction/ReceiptBill.vue')
					},
					{
						path: 'receiptSummary',
						component: () => import( /*webpackChunkName:"receiptSummary"*/
							'../views/ChildrensPage/Transaction/ReceiptSummary.vue')
					},
					{
						path: 'refund',
						component: () => import( /*webpackChunkName:"refund"*/
							'../views/ChildrensPage/Transaction/Refund.vue')
					},
					{
						path: 'transfer',
						component: () => import( /*webpackChunkName:"transfer"*/
							'../views/ChildrensPage/Transaction/Transfer.vue')
					},
					// 如果是空重定向到receipt页面
					{
						path: '',
						redirect: "receipt"
					},
				]
			},
			// 赵丽莎
			{
				path: 'acount',
				// 用到才开始加载，路由懒加载
				component: () => import( /* webpackChunkName:"Acount" */
					'../views/ChildrensPage/acount/Acount.vue'),
				children: [{
						path: "property",
						component: () => import( /* webpackChunkName: "Property" */
							'../views/ChildrensPage/acount/Property.vue')
					},
					{
						path: "income",
						component: () => import( /* webpackChunkName: "Income" */
							'../views/ChildrensPage/acount/Income.vue')
					},
					{
						path: "merchant",
						component: () => import( /* webpackChunkName: "Merchant" */
							'../views/ChildrensPage/acount/Merchant.vue')
					},
					{
						path: "reportforms",
						component: () => import( /* webpackChunkName: "ReportForms" */
							'../views/ChildrensPage/acount/ReportForms.vue')
					},
					//如果是空，重定向到dash页面
					{
						path: '',
						redirect: "property"
					}
				]
			},
			// 孙姗姗
			{
				path: 'fundmanage',
				component: () => import('../views/ChildrensPage/FundManage/FundManage.vue'),
				children: [{
						path: "settle",
						component: () => import('../views/ChildrensPage/FundManage/Settle.vue'),
					},
					{
						path: "pay",
						component: () => import('../views/ChildrensPage/FundManage/Pay.vue'),
					},
					{
						path: "shiftin",
						component: () => import('../views/ChildrensPage/FundManage/ShiftIn.vue'),
					},
					{
						path: "billload",
						component: () => import('../views/ChildrensPage/FundManage/BillLoad.vue'),
					},
					{
						path: "presettle",
						component: () => import('../views/ChildrensPage/FundManage/PreSettle.vue'),
					},
					{
						path: "batchsend",
						component: () => import('../views/ChildrensPage/FundManage/BatchSend.vue'),
					},
					{
						path: "batchget",
						component: () => import('../views/ChildrensPage/FundManage/BatchGet.vue'),
					},
					{
						path: "refund",
						component: () => import('../views/ChildrensPage/FundManage/Refund.vue'),
					},
					{
						path: "details",
						component: () => import('../views/ChildrensPage/FundManage/Details.vue'),
					},
					{
						path: "day",
						component: () => import('../views/ChildrensPage/FundManage/Day.vue'),
					},
					// 如果是空重定向到dash页面
					{
						path: "",
						redirect: "settle"
					}
				]
			},
			// 常永康
			{
				path: "cardservice",
				component: () =>
					import( /*webpackChunkName:"transfer"*/
						'../views/ChildrensPage/Cardservice/Cardservice.vue'),
				children: [{
						path: 'setween',
						component: () => import( /*webpackChunkName:"transfer"*/
							'../views/ChildrensPage/Cardservice/Setween.vue')
					},
					{
						path: 'Orderlist',
						component: () => import( /*webpackChunkName:"transfer"*/
							'../views/ChildrensPage/Cardservice/Orderlist.vue')
					},
					{
						path: 'Prepaid',
						component: () => import( /*webpackChunkName:"transfer"*/
							'../views/ChildrensPage/Cardservice/Prepaid.vue')
					},
					{
						path: 'Safe_healthy',
						component: () => import( /*webpackChunkName:"transfer"*/
							'../views/ChildrensPage/Cardservice/Safe_healthy.vue')
					},
					{
						path: '',
						redirect: "setween",

					},
				]
			},
			// 海川
			{
				path: "admin",
				component: () => import( /* webpackChunkName:"dash" */
					'../views/ChildrensPage/chajian/Admin.vue'),
				children: [{
						path: "dash",
						component: () => import('../views/ChildrensPage/chajian/Dash.vue'),
					},
					{
						path: "orderlist",
						component: () => import('../views/ChildrensPage/chajian/Orderlist.vue'),
					},
					{
						path: "three",
						component: () => import( /* webpackChunkName:"dash" */
							'../views/ChildrensPage/chajian/three.vue'),
					},
					{
						path: "",
						redirect: "dash"
					}
				]
			},
			// 赵森
			{
				path: 'minad',
				// 用到才开始加载，路由懒加载
				component: () => import( /* webpackChunkName:"minad" */
					'../views/ChildrensPage/minad/minad.vue'),
				children: [{
						path: 'dash',
						component: () => import( /*webpackChunkName:"dash"*/
							'../views/ChildrensPage/minad/Dash.vue')
					},
					{
						path: 'orderlist',
						component: () => import( /*webpackChunkName:"orderlist"*/
							'../views/ChildrensPage/minad/Orderlist.vue')
					},
					// 如果是空重定向到receipt页面
					{
						path: '',
						redirect: "dash"
					},
				]
			},
			// 如果是空重定向到dash页面
			{
				path: '',
				redirect: "acount"
			}
		],
	},
]

const router = new VueRouter({
	routes
})
// 全局路由守卫
router.beforeEach((to,from,next)=>{
	// 如果有meta属性，才需要判断
	if(to.meta.auth){
		// 如果获取到登录标识符号（已经登录）
		if(localStorage.getItem('isLog')){
			next(true)
		}else{
			next('/login?redirect='+to.path);
		}
	}else{
		next(true)
	}
})
export default router
